//
//  LVSessionCell.m
//  LEVE
//
//  Created by 上官惠阳 on 2017/3/1.
//  Copyright © 2017年 dashuju. All rights reserved.
//

#import "LVSessionCell.h"
#import "NSString+Size.h"

@interface  LVSessionCell()
@property (weak, nonatomic) IBOutlet UILabel *countLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *countWidth;
@end
@implementation LVSessionCell

- (void)awakeFromNib {
    [super awakeFromNib];

    [_rigthBtn addTarget:self action:@selector(rightAction:) forControlEvents:UIControlEventTouchUpInside];

    self.selectionStyle = UITableViewCellSelectionStyleNone;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    [self makeUI];

}
- (void)makeUI
{
    _countLabel.layer.masksToBounds = YES;
    _countLabel.layer.cornerRadius = 9;
}
- (void)rightAction:(UIButton *)btn
{
    btn.selected = !btn.selected;
    if (_rightActionBlock) {
        _rightActionBlock(btn.selected);
    }
}
- (void)setCountLabelText:(NSString *)count
{
    _countLabel.hidden = NO;
    _countLabel.text = count;
    
    CGFloat width = [count widthWithFont:[UIFont systemFontOfSize:12] constrainedToHeight:18];
    _countWidth.constant = 10 + width;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
@end
